bitkeeper revision 1.1413 (42886cbcgOQRttqbKGwhoGUdvq0jbg)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 16 May 2005 09:49:48 +0000 (09:49 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 16 May 2005 09:49:48 +0000 (09:49 +0000)
Fix the watchdog disable/enable interface. This cleans up common code
somewhat.
Signed-off-by: Keir Fraser <keir@xensource.com>
12 files changed:
xen/arch/ia64/xenmisc.c
xen/arch/x86/cdb.c
xen/arch/x86/domain.c
xen/arch/x86/nmi.c
xen/arch/x86/setup.c
xen/arch/x86/traps.c
xen/arch/x86/x86_32/traps.c
xen/arch/x86/x86_64/traps.c
xen/common/page_alloc.c
xen/drivers/char/console.c
xen/include/asm-ia64/config.h
xen/include/asm-x86/apic.h

index 85f0bddc6936be10e746a6ded2d56c36b8d1dc44..15ed4af4ea909817731be78f9128727aac3d664a 100644 (file)
@@ -23,8 +23,6 @@ unsigned long wait_init_idle;
 int phys_proc_id[NR_CPUS];
 unsigned long loops_per_jiffy = (1<<12);       // from linux/init/main.c
 
-unsigned int watchdog_on = 0;  // from arch/x86/nmi.c ?!?
-
 void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); }
 void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); }
 void ia64_mca_cpu_init(void *x) { }
index 451ce46853e23682dec678e8d3d2418c2f3ad44d..899493380fad051ae30d13a9f9899f61f85cf7d9 100644 (file)
@@ -327,7 +327,6 @@ __trap_to_cdb(struct cpu_user_regs *regs)
        static atomic_t xendbg_running = ATOMIC_INIT(1);
        static char recv_buf[4096];
        unsigned flags;
-       unsigned old_watchdog;
 
        if (xdb_ctx.serhnd < 0) {
                dbg_printk("Debugger not ready yet.\n");
@@ -358,8 +357,7 @@ __trap_to_cdb(struct cpu_user_regs *regs)
           interrupts while we're here. */
        local_irq_save(flags);
 
-       old_watchdog = watchdog_on;
-       watchdog_on = 0;
+       watchdog_disable();
 
        /* Shouldn't really do this, but otherwise we stop for no
           obvious reason, which is Bad */
@@ -385,7 +383,7 @@ __trap_to_cdb(struct cpu_user_regs *regs)
                        ASSERT(!local_irq_is_enabled());
                }
        }
-       watchdog_on = old_watchdog;
+       watchdog_enable();
        atomic_inc(&xendbg_running);
        local_irq_restore(flags);
        return 0;
index 22fea7eb82177ee66709fbfc7252b9c111520828..6e69cf32cd804a697227a45348165e8b52bb3364 100644 (file)
@@ -186,7 +186,7 @@ void __attribute__((noreturn)) __machine_halt(void *unused)
 
 void machine_halt(void)
 {
-    watchdog_on = 0;
+    watchdog_disable();
     smp_call_function(__machine_halt, NULL, 1, 0);
     __machine_halt(NULL);
 }
index afdf8051bbda7a4a1adc0ab8e95a7525e5506abd..aef14645e46930e6a14d39ecadc3fdabda6fbd08 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/debugger.h>
 
 unsigned int nmi_watchdog = NMI_NONE;
-unsigned int watchdog_on = 0;
 static unsigned int nmi_hz = HZ;
 unsigned int nmi_perfctr_msr;  /* the MSR to reset in NMI handler */
 
@@ -256,6 +255,28 @@ static unsigned int
 last_irq_sums [NR_CPUS],
     alert_counter [NR_CPUS];
 
+static spinlock_t   watchdog_lock = SPIN_LOCK_UNLOCKED;
+static unsigned int watchdog_disable_count = 1;
+static unsigned int watchdog_on;
+
+void watchdog_disable(void)
+{
+    unsigned long flags;
+    spin_lock_irqsave(&watchdog_lock, flags);
+    if ( watchdog_disable_count++ == 0 )
+        watchdog_on = 0;
+    spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
+void watchdog_enable(void)
+{
+    unsigned long flags;
+    spin_lock_irqsave(&watchdog_lock, flags);
+    if ( --watchdog_disable_count == 0 )
+        watchdog_on = 1;
+    spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
 void touch_nmi_watchdog (void)
 {
     int i;
index c6a5f2c55bfc265cac54ac5b304de7ebbeef91e8..cb75477f039be2b1533b77d1726488319f4563ea 100644 (file)
@@ -450,7 +450,8 @@ static void __init start_of_day(void)
     while ( wait_init_idle != 0 )
         cpu_relax();
 
-    watchdog_on = 1;
+    watchdog_enable();
+
 #ifdef __x86_64__ /* x86_32 uses low mappings when building DOM0. */
     zap_low_mappings();
 #endif
index fc723bf998cdc123306a0ed9b5762239ebad22a7..d68539df88b391e18f5d433551e683cc72bb3af0 100644 (file)
@@ -199,7 +199,7 @@ asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs)
         "machine check", "simd error"
     };
 
-    watchdog_on = 0;
+    watchdog_disable();
 
     show_registers(regs);
 
index 9f924831ef81ac0efe40e7ed0beb0ba6566e10de..4d7c94e1b9de21496e8ccf65780792134eeb947b 100644 (file)
@@ -111,8 +111,7 @@ asmlinkage void do_double_fault(void)
     struct tss_struct *tss = &doublefault_tss;
     unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1;
 
-    /* Disable the NMI watchdog. It's useless now. */
-    watchdog_on = 0;
+    watchdog_disable();
 
     console_force_unlock();
 
index d48ae32fded6a59a13f953e4f24961bbcb721cb3..853dd95a381400835d6970dd21e454170861ff34 100644 (file)
@@ -60,8 +60,7 @@ void show_page_walk(unsigned long addr)
 asmlinkage void double_fault(void);
 asmlinkage void do_double_fault(struct cpu_user_regs *regs)
 {
-    /* Disable the NMI watchdog. It's useless now. */
-    watchdog_on = 0;
+    watchdog_disable();
 
     console_force_unlock();
 
index 8669ac8a27d76490e9790e644187fde9bc24c968..e37422f962069d147c5810a071481b13354b0230 100644 (file)
@@ -356,15 +356,13 @@ void scrub_heap_pages(void)
     unsigned long pfn, flags;
 
     printk("Scrubbing Free RAM: ");
+    watchdog_disable();
 
     for ( pfn = 0; pfn < (bitmap_size * 8); pfn++ )
     {
-        /* Every 100MB, print a progress dot and appease the watchdog. */
+        /* Every 100MB, print a progress dot. */
         if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
-        {
             printk(".");
-            touch_nmi_watchdog();
-        }
 
         /* Quick lock-free check. */
         if ( allocated_in_map(pfn) )
@@ -383,6 +381,7 @@ void scrub_heap_pages(void)
         spin_unlock_irqrestore(&heap_lock, flags);
     }
 
+    watchdog_enable();
     printk("done.\n");
 }
 
index c873901e7b7afc78122e7cd5f2a43f409336c234..de598bc1145291803cfc7cfd7d0a6e1115c71486 100644 (file)
@@ -502,14 +502,12 @@ integer_param("debugtrace", debugtrace_kilobytes);
 
 void debugtrace_dump(void)
 {
-    int _watchdog_on = watchdog_on;
     unsigned long flags;
 
     if ( (debugtrace_bytes == 0) || !debugtrace_used )
         return;
 
-    /* Watchdog can trigger if we print a really large buffer. */
-    watchdog_on = 0;
+    watchdog_disable();
 
     spin_lock_irqsave(&debugtrace_lock, flags);
 
@@ -529,7 +527,7 @@ void debugtrace_dump(void)
 
     spin_unlock_irqrestore(&debugtrace_lock, flags);
 
-    watchdog_on = _watchdog_on;
+    watchdog_enable();
 }
 
 void debugtrace_printk(const char *fmt, ...)
@@ -635,7 +633,7 @@ void panic(const char *fmt, ...)
     __putstr("Reboot in five seconds...\n");
     spin_unlock_irqrestore(&console_lock, flags);
 
-    watchdog_on = 0;
+    watchdog_disable();
     mdelay(5000);
     machine_restart(0);
 }
index 9b656e493bf17bae8bf502a0e11fa017c9e9a18f..df5aef08249b4b4fc555d27a88c5493bfcbf4fa8 100644 (file)
@@ -29,7 +29,8 @@ typedef int pid_t;
 #define FASTCALL(x) x  // see linux/include/linux/linkage.h
 #define fastcall       // " "
 
-#define touch_nmi_watchdog()
+#define watchdog_disable() ((void)0)
+#define watchdog_enable()  ((void)0)
 // from linux/include/linux/types.h
 #define CLEAR_BITMAP(name,bits) \
        memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
@@ -261,7 +262,6 @@ struct screen_info { };
 // these declarations got moved at some point, find a better place for them
 extern int opt_noht;
 extern int ht_per_core;
-extern unsigned int watchdog_on;
 
 // xen/include/asm/config.h
 /******************************************************************************
index 73112359a5bcccdff8270fed2fa4858a70472ec1..dcced35f7967b60a3bec2e0b1df9f51d4fe5548f 100644 (file)
@@ -104,15 +104,16 @@ extern void release_lapic_nmi(void);
 extern void disable_timer_nmi_watchdog(void);
 extern void enable_timer_nmi_watchdog(void);
 extern void nmi_watchdog_tick (struct cpu_user_regs *regs);
-extern void touch_nmi_watchdog(void);
 extern int APIC_init_uniprocessor (void);
 extern void disable_APIC_timer(void);
 extern void enable_APIC_timer(void);
 
-extern unsigned int watchdog_on;
 extern int check_nmi_watchdog (void);
 extern void enable_NMI_through_LVT0 (void * dummy);
 
+extern void watchdog_disable(void);
+extern void watchdog_enable(void);
+
 extern unsigned int nmi_watchdog;
 #define NMI_NONE       0
 #define NMI_IO_APIC    1